import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) {
            int n = in.nextInt();
            int maxCount = 0;
            int currentCount = 0;

            while (n > 0) {
                if ((n & 1) == 1) {
                    currentCount++;
                } else {
                    maxCount = Math.max(maxCount, currentCount);
                    currentCount = 0;
                }
                n >>= 1;
            }
            maxCount = Math.max(maxCount, currentCount);

            System.out.println(maxCount);
        }
    }
}